<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/WEB-INF/templates/default.xhtml">
	<ui:define name="content">
		<h3>Vehicle Panel</h3>

		<h:form id="createVehicle" rendered="#{login.admin}">
			<h:panelGroup rendered="#{empty vehicleController.vehicles}">
				<em>No results.</em>
			</h:panelGroup>
			<h:dataTable var="_vehicle" value="#{vehicleController.vehicles}" rendered="#{not empty vehicleController.vehicles}" styleClass="simpletablestyle">
				<h:column>
					<f:facet name="header">Make</f:facet>
                #{_vehicle.vehicleModel.vehicleMake.makeName}
            </h:column>

				<h:column>
					<f:facet name="header">Model</f:facet>
                #{_vehicle.vehicleModel.modelName}
            </h:column>
				<h:column>
					<f:facet name="header">Modification</f:facet>
                #{_vehicle.vehicleModification.modificationName}
            </h:column>
				<h:column>
					<f:facet name="header">Color</f:facet>
                #{_vehicle.color.colorName}
            </h:column>
				<h:column>
					<f:facet name="header">VIN</f:facet>
                #{_vehicle.vin}
            </h:column>
				<h:column>
					<f:facet name="header">Plate Number</f:facet>
                #{_vehicle.plateNumber}
            </h:column>
				<h:column>
					<f:facet name="header">action</f:facet>
					<h:commandLink
						action="#{vehicleController.selectVehicle(_vehicle)}"
						value="Go to maintenances" />
				</h:column>
			</h:dataTable>
			</h:form>
			<h:form>
			<h:panelGroup id="selectPanel">
				<h:selectOneMenu
					value="#{vehicleController.currentMake.vehicleMakeId}"
					onchange="submit()">
					<f:selectItem itemLabel="Make" />
					<f:selectItems value="#{vehicleController.makes}" var="_make"
						itemValue="#{_make.vehicleMakeId}" itemLabel="#{_make.makeName}" />
				</h:selectOneMenu>
				<h:selectOneMenu
					value="#{vehicleController.currentModel.vehicleModelId}"
					onchange="submit()">
					<f:selectItem itemLabel="Model" />
					<f:selectItems value="#{vehicleController.currentModels}"
						var="_model" itemValue="#{_model.vehicleModelId}"
						itemLabel="#{_model.modelName}" />
				</h:selectOneMenu>
				<h:selectOneMenu
					value="#{vehicleController.currentModification.vehicleModificationId}"
					onchange="submit()">
					<f:selectItem itemLabel="Modification" />
					<f:selectItems value="#{vehicleController.currentModifications}"
						var="_modification"
						itemValue="#{_modification.vehicleModificationId}"
						itemLabel="#{_modification.modificationName}" />
				</h:selectOneMenu>
				<h:selectOneMenu
					value="#{vehicleController.newVehicle.color.colorId}">
					<f:selectItem itemLabel="Color" />
					<f:selectItems value="#{vehicleController.colors}" var="_color"
						itemValue="#{_color.colorId}" itemLabel="#{_color.colorName}" />
				</h:selectOneMenu>
				<h:panelGrid columns="2">
					<h:outputLabel value="VIN:" />
					<h:inputText value="#{vehicleController.newVehicle.vin}" />
					<h:outputLabel value="Plate Number:" />
					<h:inputText value="#{vehicleController.newVehicle.plateNumber}" />
					<h:outputLabel value="Odometer:" />
					<h:inputText value="#{vehicleController.newVehicle.odometer}" />
				</h:panelGrid>
			</h:panelGroup>
			<h:commandButton action="#{vehicleController.saveVehicle}"
				value="Save" />
		</h:form>

	</ui:define>
</ui:composition>